﻿using System.Collections.ObjectModel;
using VisionDesigner;
using VM.Common.Helper;

namespace VM.Start.ViewModels.Dock
{
    public class VisionViewModel : NotifyPropertyBase
    {
        #region Singleton
        private static readonly VisionViewModel _instance = new VisionViewModel();
        private VisionViewModel()
        {
            ShowShapes = new ObservableCollection<CMvdShape>();
        }
        public static VisionViewModel Ins => _instance;
        #endregion

        private CMvdImage _ShowImage;
        public CMvdImage ShowImage
        {
            get { return _ShowImage; }
            set
            {
                if (_ShowImage != value)
                {
                    // 释放旧的图像对象
                    _ShowImage?.Dispose();

                    // 分配新值
                    Set(ref _ShowImage, value);
                }
            }
        }

        private ObservableCollection<CMvdShape> _showShapes;
        public ObservableCollection<CMvdShape> ShowShapes
        {
            get => _showShapes;
            set => Set(ref _showShapes, value);
        }

        private bool _ClearContent;
        public bool ClearContent
        {
            get { return _ClearContent; }
            set { Set(ref _ClearContent, value); }
        }

        // 更新图像和形状的方法
        public void UpdateImageAndShapes(CMvdImage? newImage, ObservableCollection<CMvdShape>? newShapes)
        {
            ShowImage = newImage;
            ShowShapes = newShapes;
        }

    }
}
